﻿using System;

namespace Common
{
    /// <summary>
    ///下载
    /// </summary>
    public class DownloadEventArgs : EventArgs
    {
        private DownloadResult _downloadResult = DownloadResult.Ok;
        /// <summary>
        /// 下载文件的结果
        /// </summary>
        public DownloadResult QueueDownloadResult
        {
            get { return _downloadResult; }
            set { _downloadResult = value; }
        }

        private long _receiveBytes;
        /// <summary>
        /// 已經下載完成的字節數
        /// </summary>
        public long ReceivedBytes
        {
            get { return _receiveBytes; }
            set
            {
                if (value < 0)
                {
                    return;
                }
                this._receiveBytes = value;
            }
        }

        private long _totalBytes;

        /// <summary>
        /// 文件的總大小
        /// </summary>
        public long TotalBytes
        {
            get { return _totalBytes; }
            set
            {
                if (value < 0)
                {
                    return;
                }
                this._totalBytes = value;
            }
        }

        public DownloadEventArgs()
        {
            _downloadResult = DownloadResult.Ok;
        }

        public DownloadEventArgs(DownloadResult downloadResult)
        {
            this._downloadResult = downloadResult;
        }

        public DownloadEventArgs(DownloadResult downloadResult, long receivedBytes, long totalBytes)
            : this(downloadResult)
        {
            this.TotalBytes = totalBytes;
            this.ReceivedBytes = receivedBytes;
        }
    }

    public delegate void DownloadEvent(object sender, DownloadEventArgs e);
}
